﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iesi.Collections.Generic;

namespace Apodidae.Domain.Entity
{
    public class GroupInfo : BaseObject<Int32>
    {
        public GroupInfo()
        {
            Students = new HashedSet<UserInfo>();
        }


        /// <summary>
        /// 小组长
        /// </summary>
        public virtual UserInfo GroupMaster { get; set; }
        public void SetGroupMaster(UserInfo groupMaster)
        {
            this.GroupMaster = groupMaster;
            groupMaster.MasteredGroup = this;
        }

        /// <summary>
        /// 多对一: 多个组，可以在一个班级
        /// </summary>
        public virtual ClassInfo ClassInfo { get; set; }

        /// <summary>
        /// 一对多：一个组有多个学生
        /// </summary>
        public virtual ISet<UserInfo> Students { get; set; }
        public void AddStudents(UserInfo student)
        {
            student.GroupInfo = this;
            this.Students.Add(student);
        }
        public void RemoveStudents(UserInfo student)
        {
            this.Students.Remove(student);
        }
    }
}
